package top.dotgo.kit.bean;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * @author jornl
 * @date 2019-10-13 21:51:52
 */
@Getter
@Setter
@Accessors(chain = true)
public class Page<T> {
    /***
     * 当前页
     */
    private int page;
    /**
     * 每页条数
     */
    private int size;
    /**
     * 总页数
     */
    private int total;
    /**
     * 总行数
     */
    private int count;

    /**
     * 是否空
     */
    private boolean empty;

    /**
     * 数据
     */
    private List<T> list;

    public Page<T> setList(List<T> list) {
        this.list = list;
        this.empty = list == null || list.isEmpty();
        return this;
    }


    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
